package cn.cheln.explorer.ds;

import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import cn.cheln.explorer.ds.database.SQLManager;

public class OtherFileProvider extends ContentProvider
{
  private static final int FOLDER = 5;
  private static final int IMAGE = 3;
  private static final int TABLES = 1;
  private static final int TABLE_ID = 2;
  private static final String TABLE_NAME = "files";
  private static final UriMatcher sUriMatcher = new UriMatcher(-1);
  SQLiteDatabase db;
  int i = 1;
  DatabaseHelper mOpenHelper;

  static
  {
    sUriMatcher.addURI("com.lewa.app.filemanager", "files", 1);
    sUriMatcher.addURI("com.lewa.app.filemanager", "image", 3);
    sUriMatcher.addURI("com.lewa.app.filemanager", "dir", 5);
    sUriMatcher.addURI("com.lewa.app.filemanager", "files/#", 2);
  }

  private String getTable(Uri paramUri)
  {
    switch (sUriMatcher.match(paramUri))
    {
    case 2:
    case 4:
    default:
      throw new IllegalArgumentException("Unknown URI " + paramUri);
    case 1:
      return SQLManager.tablename;
    case 3:
      return SQLManager.tableimage;
    case 5:
    }
    return SQLManager.tabledir;
  }

  public int delete(Uri paramUri, String paramString, String[] paramArrayOfString)
  {
    return this.mOpenHelper.getWritableDatabase().delete(getTable(paramUri), paramString, paramArrayOfString);
  }

  public SQLiteDatabase getDatabase()
  {
    if ((this.db == null) || (!(this.db.isOpen())))
      this.db = this.mOpenHelper.getReadableDatabase();
    return this.db;
  }

  public String getType(Uri paramUri)
  {
    switch (sUriMatcher.match(paramUri))
    {
    case 4:
    default:
      throw new IllegalArgumentException("Unknown URI " + paramUri);
    case 1:
      return "vnd.Android.cursor.dir/vnd.lewa.files";
    case 2:
      return "vnd.Android.cursor.item/vnd.cheln.files";
    case 3:
      return "vnd.Android.cursor.item/vnd.cheln.image";
    case 5:
    }
    return "vnd.Android.cursor.item/vnd.cheln.folder";
  }

  public Uri insert(Uri paramUri, ContentValues paramContentValues)
  {
    String str = getTable(paramUri);
    if (paramContentValues != null);
    for (ContentValues localContentValues = new ContentValues(paramContentValues); ; localContentValues = new ContentValues())
    {
      long l = this.mOpenHelper.getWritableDatabase().insert(str, null, localContentValues);
      if (l <= 0L)
        break;
      return ContentUris.withAppendedId(paramUri, l);
    }
    throw new SQLException("Failed to insert row into " + paramUri);
  }

  public boolean onCreate()
  {
    this.mOpenHelper = new DatabaseHelper(getContext());
    return true;
  }

  public Cursor query(Uri paramUri, String[] paramArrayOfString1, String paramString1, String[] paramArrayOfString2, String paramString2)
  {
    SQLiteQueryBuilder localSQLiteQueryBuilder = new SQLiteQueryBuilder();
    localSQLiteQueryBuilder.setTables(getTable(paramUri));
    return localSQLiteQueryBuilder.query(getDatabase(), paramArrayOfString1, paramString1, paramArrayOfString2, null, null, paramString2);
  }

  public int update(Uri paramUri, ContentValues paramContentValues, String paramString, String[] paramArrayOfString)
  {
    String str = getTable(paramUri);
    return getDatabase().update(str, paramContentValues, paramString, paramArrayOfString);
  }
}

/* Location:           H:\360云盘\lewa_explorer_3.0\bin\FileApp_orig_dex2jar.jar
 * Qualified Name:     cn.cheln.explorer.ds.OtherFileProvider
 * JD-Core Version:    0.5.2
 */